import { IPSAppDEField } from '../../app/dataentity/ipsapp-defield';
import { IPSNavigateContext } from '../ipsnavigate-context';
import { IPSNavigateParam } from '../ipsnavigate-param';
import { IPSDETree } from './ipsdetree';
import { IPSDETreeNode } from './ipsdetree-node';
import { IPSDETreeNodeRS } from './ipsdetree-node-rs';
import { IPSDETreeNodeRSParam } from './ipsdetree-node-rsparam';
import { IPSDER1N } from '../../dataentity/der/ipsder1-n';
import { PSModelObjectImpl } from '../../psmodel-object-impl';

export class PSDETreeNodeRSImpl extends PSModelObjectImpl implements IPSDETreeNodeRS {
  protected childpsdetreenode: IPSDETreeNode | null = null;

  getChildPSDETreeNode(): IPSDETreeNode | null {
    if (this.childpsdetreenode != null) return this.childpsdetreenode;
    const value = this.M.getChildPSDETreeNode;
    if (value == null) {
      return null;
    }
    const ipsdetree = this.getParentPSModelObject('control.tree.IPSDETree') as IPSDETree;
    if (ipsdetree != null) {
      this.childpsdetreenode = ipsdetree.findPSDETreeNode(value);
    }
    return this.childpsdetreenode;
  }

  get childPSDETreeNode(): IPSDETreeNode | null {
    return this.getChildPSDETreeNode();
  }

  getChildPSDETreeNodeMust(): IPSDETreeNode {
    const value = this.getChildPSDETreeNode();
    if (value == null) {
      throw new Error('未指定下级节点对象');
    }
    return value;
  }

  get codeName(): string {
    return this.M.codeName;
  }

  get dynaModelFilePath(): string {
    return this.M.dynaModelFilePath;
  }

  get memo(): string {
    return this.M.memo;
  }

  get name(): string {
    return this.M.name;
  }

  protected psdetreenodersparams: IPSDETreeNodeRSParam[] | null = null;

  getPSDETreeNodeRSParams(): IPSDETreeNodeRSParam[] | null {
    if (this.psdetreenodersparams == null) {
      this.psdetreenodersparams = this.fillChildListModel(this.M.getPSDETreeNodeRSParams, 'control.tree.IPSDETreeNodeRSParam') as IPSDETreeNodeRSParam[];
    }
    return this.psdetreenodersparams;
  }

  get psDETreeNodeRSParams(): IPSDETreeNodeRSParam[] | null {
    return this.getPSDETreeNodeRSParams();
  }

  findPSDETreeNodeRSParam(objKey: any): IPSDETreeNodeRSParam | null {
    return this.getPSModel5('control.tree.IPSDETreeNodeRSParam', this.getPSDETreeNodeRSParams(), objKey) as IPSDETreeNodeRSParam;
  }

  protected psnavigatecontexts: IPSNavigateContext[] | null = null;

  getPSNavigateContexts(): IPSNavigateContext[] | null {
    if (this.psnavigatecontexts == null) {
      this.psnavigatecontexts = this.fillChildListModel(this.M.getPSNavigateContexts, 'control.IPSNavigateContext') as IPSNavigateContext[];
    }
    return this.psnavigatecontexts;
  }

  get psNavigateContexts(): IPSNavigateContext[] | null {
    return this.getPSNavigateContexts();
  }

  findPSNavigateContext(objKey: any): IPSNavigateContext | null {
    return this.getPSModel5('control.IPSNavigateContext', this.getPSNavigateContexts(), objKey) as IPSNavigateContext;
  }

  protected psnavigateparams: IPSNavigateParam[] | null = null;

  getPSNavigateParams(): IPSNavigateParam[] | null {
    if (this.psnavigateparams == null) {
      this.psnavigateparams = this.fillChildListModel(this.M.getPSNavigateParams, 'control.IPSNavigateParam') as IPSNavigateParam[];
    }
    return this.psnavigateparams;
  }

  get psNavigateParams(): IPSNavigateParam[] | null {
    return this.getPSNavigateParams();
  }

  findPSNavigateParam(objKey: any): IPSNavigateParam | null {
    return this.getPSModel5('control.IPSNavigateParam', this.getPSNavigateParams(), objKey) as IPSNavigateParam;
  }

  get parentFilter(): string {
    return this.M.parentFilter;
  }

  protected parentpsappdefield: IPSAppDEField | null = null;

  getParentPSAppDEField(): IPSAppDEField | null {
    if (this.parentpsappdefield != null) return this.parentpsappdefield;
    const value = this.M.getParentPSAppDEField;
    if (value == null) {
      return null;
    }
    this.parentpsappdefield = this.getChildPSDETreeNodeMust().getPSAppDataEntityMust().findPSAppDEField(value);
    return this.parentpsappdefield;
  }

  get parentPSAppDEField(): IPSAppDEField | null {
    return this.getParentPSAppDEField();
  }

  getParentPSAppDEFieldMust(): IPSAppDEField {
    const value = this.getParentPSAppDEField();
    if (value == null) {
      throw new Error('未指定父关系连接属性');
    }
    return value;
  }

  protected parentpsder1n: IPSDER1N | null = null;

  getParentPSDER1N(): IPSDER1N | null {
    if (this.parentpsder1n != null) return this.parentpsder1n;
    const value = this.M.getParentPSDER1N;
    if (value == null) {
      return null;
    }
    this.parentpsder1n = this.getPSModel4('dataentity.der.IPSDER1N', value, 'getParentPSDER1N') as IPSDER1N;
    return this.parentpsder1n;
  }

  get parentPSDER1N(): IPSDER1N | null {
    return this.getParentPSDER1N();
  }

  getParentPSDER1NMust(): IPSDER1N {
    const value = this.getParentPSDER1N();
    if (value == null) {
      throw new Error('未指定父值关系');
    }
    return value;
  }

  protected parentpsdetreenode: IPSDETreeNode | null = null;

  getParentPSDETreeNode(): IPSDETreeNode | null {
    if (this.parentpsdetreenode != null) return this.parentpsdetreenode;
    const value = this.M.getParentPSDETreeNode;
    if (value == null) {
      return null;
    }
    const ipsdetree = this.getParentPSModelObject('control.tree.IPSDETree') as IPSDETree;
    if (ipsdetree != null) {
      this.parentpsdetreenode = ipsdetree.findPSDETreeNode(value);
    }
    return this.parentpsdetreenode;
  }

  get parentPSDETreeNode(): IPSDETreeNode | null {
    return this.getParentPSDETreeNode();
  }

  getParentPSDETreeNodeMust(): IPSDETreeNode {
    const value = this.getParentPSDETreeNode();
    if (value == null) {
      throw new Error('未指定上级节点对象');
    }
    return value;
  }

  get parentValueLevel(): 1 | 2 | 3 {
    return this.M.parentValueLevel;
  }

  get searchMode(): 1 | 2 | 3 {
    return this.M.searchMode;
  }

  get userCat(): string {
    return this.M.userCat;
  }

  get userTag(): string {
    return this.M.userTag;
  }

  get userTag2(): string {
    return this.M.userTag2;
  }

  get userTag3(): string {
    return this.M.userTag3;
  }

  get userTag4(): string {
    return this.M.userTag4;
  }

  get cls(): string {
    return 'PSDETreeNodeRSImpl';
  }

  instanceof(cls: string): boolean {
    if (cls == 'control.IPSNavigateParamContainer' || cls == 'control.tree.IPSDETreeNodeRS') return true;
    return super.instanceof(cls);
  }
}
